

<template>
  <router-view />

  <div id="dscDiv">
    <video id="dscVideo">
      <source src="/dsc/dscnygsm.mp4" type="video/mp4" />
    </video>
  </div>
</template>

<script setup>
const route = useRoute();

watch(
  () => route.name,
  (newV, oldV) => {
    if (newV != "Zhongxin") {
      //页面打开后至于最顶部
      window.scrollTo({
        top: 0,
      });
    }
  }
);

//禁用f12
if (window.location.hostname != "localhost") {
  document.addEventListener("DOMContentLoaded", function () {
    window.addEventListener("keydown", function (e) {
      if (e.key === "F12" || (e.ctrlKey && e.shiftKey && e.keyCode === 73)) {
        //禁用F12
        e.preventDefault();

        //弹出视频
        document.getElementById("dscDiv").style.display = "block";
        document.getElementById("dscVideo").play();
        setTimeout(() => {
          document.getElementById("dscDiv").style.display = "none";
        }, 2500);
      }
    });
  });
}

// 定义一个方法来阻止右键菜单
const preventContextMenu = (event) => event.preventDefault();
onMounted(() => {
  // 组件挂载时添加事件监听器
  document.addEventListener("contextmenu", preventContextMenu);
});
onUnmounted(() => {
  // 组件卸载前移除事件监听器
  document.removeEventListener("contextmenu", preventContextMenu);
});
</script>

<style scoped>
#dscDiv {
  z-index: 999999;
  display: none;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.8);
  position: fixed;
  top: 0;
}

#dscVideo {
  width: 30vw;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>

